import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

const routes = [
  //登录页
  {
    path: '/',
    name: 'login',
    component: () => import('../views/user/loginPage.vue')
  },
  {
    path: '/message',
    name: 'message',
    component: () => import('../views/message/myMessage.vue')
  },
  {
    path: '/getNews',
    name: 'getNews',
    component: () => import('../views/find/getNew.vue')
  },
  {
    path: '/forgetpass',
    name: 'forgetpass',
    component: () => import('../views/user/forgetPass.vue')
  },
  {
    path: '/about',
    name: 'about',
    component: () => import('../views/AboutView.vue')
  },
  //主页
  {
    path: '/homepage',
    name: 'homepage',
    component: () => import('../views/homepage/homePage.vue')
  },
  // 点餐页面
  {
    path: '/orderfood',
    name: 'orderfood',
    component: () => import('../views/orderfood/orderFood.vue')
  },
  //订单页面
  {
    path: '/order',
    name: 'order',
    component: () => import('../views/order/orderPage.vue')
  },
  //我的页面
  {
    path: '/my',
    name: 'my',
    component: () => import('../views/my/myPage.vue')
  },
  //新增地址
  {
    path: '/addAddress',
    name: 'addAddress',
    component: () => import('../views/address/addAddress.vue')
  },
  //地址管理
  {
    path: '/address',
    name: 'address',
    component: () => import('../views/address/addressPage.vue')
  },
  //修改密码
  {
      path: '/modifypwd',
      name: 'modifypwd',
      component: () => import('../views/user/modifyPassword.vue')
  },
  //充值管理
  {
    path: '/sendMoney',
    name: 'sendMoney',
    component: () => import('../views/user/sendMoney.vue')
  },
  //关于我们
  {
    path: '/aboutUs',
    name: 'aboutus',
    component: () => import('../views/user/aboutUs.vue')
  },
  //联系我们
  {
    path: '/contactUs',
    name: 'contactUs',
    component: () => import('../views/user/contactUs.vue')
  },
  //注册用户
  {
    path: '/addUser',
    name: '注册用户',
    component: () => import('../views/user/registerUser.vue')
  },
  {
    path: '/reRecord',
    name: '充值记录',
    component: () => import('../views/user/rechargeRecord.vue')
  },
]

//这段代码解决重复点击导航栏，控制台报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
